<%--
  Created by IntelliJ IDEA.
  User: 13095
  Date: 2024/9/18
  Time: 12:15
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<c:set value="${pageContext.request.contextPath}" var="path"></c:set>
<html>
<head>
    <meta charset="UTF-8">
    <title>可接任务</title>
    <script src="${path}/static/js/jquery-3.2.1.min.js"></script>
    <link rel="stylesheet" href="${path}/static/css/staffcss.css">
    <script src="${path}/static/js/script.js"></script>

</head>
<body>
<div class="container">
    <header>
        <c:if test="${requestScope.ordersPageInfo.list.size()!=0&&requestScope.ordersPageInfo!=null}">
            <h1>可接任务</h1>
        </c:if>
        <c:if test="${requestScope.ordersPageInfo.list.size()==0}">
            <h1 style="color: red">没有可接任务</h1>
        </c:if>
        <c:if test="${requestScope.ordersPageInfo==null}">
            <h1 style="color: red">可接取任务到达上限</h1>
        </c:if>
        <jsp:include page="inc/inc.jsp"></jsp:include>
    </header>
    <main>
        <c:if test="${requestScope.ordersPageInfo!=null}">
            <table>
                <tr>
                    <th>任务编号</th>
                    <th>描述</th>
                    <th>地点</th>
                    <th>佣金</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${requestScope.ordersPageInfo.list}" var="orders">
                    <tr>
                        <td>${orders.orderNumber}</td>
                        <td>${orders.task.description}</td>
                        <td>${orders.task.location}</td>
                        <td>${(orders.task.reward)*7/10}</td>
                        <td><a href="${path}/runner/accept?id=${orders.id}">接取</a></td>
                    </tr>
                </c:forEach>
            </table>

            <!-- 分页导航开始 -->
            <div class="pagination">
                <c:if test="${requestScope.ordersPageInfo.hasPreviousPage}">
                    <a href="${path}/runner/availableTaskList?page=${requestScope.ordersPageInfo.pageNum - 1}" title="上一页">上一页</a>
                </c:if>
                <c:forEach begin="1" end="${requestScope.ordersPageInfo.pages}" var="pageNum">
                    <c:choose>
                        <c:when test="${pageNum == requestScope.ordersPageInfo.pageNum}">
                            <span class="current-page" title="当前页：${pageNum}">${pageNum}</span>
                        </c:when>
                        <c:otherwise>
                            <a href="${path}/runner/availableTaskList?page=${pageNum}" title="跳转到第 ${pageNum} 页">${pageNum}</a>
                        </c:otherwise>
                    </c:choose>
                </c:forEach>
                <c:if test="${requestScope.ordersPageInfo.hasNextPage}">
                    <a href="${path}/runner/availableTaskList?page=${requestScope.ordersPageInfo.pageNum + 1}" title="下一页">下一页</a>
                </c:if>
            </div>
            <!-- 分页导航结束 -->
        </c:if>
    </main>
</div>
</body>
</html>